import { defineConfig, loadEnv } from "vite";
import vue from "@vitejs/plugin-vue";
import path from "path";
// https://vitejs.dev/config/
export default defineConfig(({ mode }) => {
  const env = loadEnv(mode, process.cwd());
  return {
    plugins: [vue()],
    resolve: {
      alias: {
        "@": path.resolve(__dirname, "./src"),
        "~": path.resolve(__dirname, "./"),
      },
    },
    server: {
      host: true,
      open: false,
      proxy: {
        ["/zs-dev"]: {
          // target: "https://api.ownthink.com/bot",
          target: "https://api.sizhi.com",
          changeOrigin: true,
          secure: true,
          rewrite: (path) => path.replace(new RegExp("^" + "/zs-dev"), ""),
        }, // base api
        ["/dev"]: {
          target: "http://8.130.151.97:8081",
          changeOrigin: true,
          secure: true,
          rewrite: (path) => path.replace(new RegExp("^" + "/dev"), ""),
        },
        // ['/aly-dev']: {
        //   target: "https://fanzhiedu.oss-cn-chengdu.aliyuncs.com",
        //   changeOrigin: true,
        //   secure: true,
        //   pathRewrite: {
        //     ["^" + process.env.VUE_ALY_BASE_API]: "",
        //   },
        // },
      }, // proxy
    }, //server
  };
});
